package org.biblicalcontent.ui.generiek;

import org.eclipse.ui.PlatformUI;

public final class ServiceProvider {

	private static final ServiceProvider INSTANCE = new ServiceProvider();

	private ServiceProvider() {
		// doe niets.
	}

	public static ServiceProvider getInstance() {
		return INSTANCE;
	}

	public <T> T getService(Class<T> clazz) {
		@SuppressWarnings("unchecked")
		T service = (T) PlatformUI.getWorkbench().getService(clazz);
		if (service == null) {
			throw new IllegalArgumentException(String.format("Service %s is niet gevonden.", clazz.getName()));
		}
		return service;
	}
}
